
import{getgooddetail,getgoodcomment,getRecommendShopList,gogetsearch} from '@/api/index'

const state={
  goodsdetail:{},
  goodscomment:{},
  recommendshopist:{},
  seagoods:{}//模糊查询商品

  

}
const actions={
  //获取商品详细
  async goodsdetail({commit},id){
    let result=await getgooddetail(id)
    commit("GOODDETAIL",{goods:result.data.msg})

},
//获取评论
async goodcomment({commit},id){
  let result=await getgoodcomment(id)
 commit("GOODCOMMENT",{commit:result.data.msg})
},
//推荐商品数据
async reqRecommendShopList({commit},params){
  const result= await getRecommendShopList(params)
  commit("REQRECOMMENDSHOPLIST",{recommendshopist:result.data.msg})
},
//模糊查询
async getsearch({commit},params){
  let result=await gogetsearch(params)
  if(result.data.code==200){
    commit("serchgoods",{goods:result.data.msg})
  }else{
    commit("serchgoods",{goods:[]})

}
}
}
const mutations={
  GOODDETAIL(state,{goods}){
    state. goodsdetail=goods
  },
  GOODCOMMENT(state,{commit}){
state.goodscomment=commit
  },
  REQRECOMMENDSHOPLIST(state,{recommendshopist}){
    state.recommendshopist=recommendshopist
  },
  serchgoods(state,{goods}){
state.seagoods=goods
  }
  
  
}
export default{
  namespaced: true,//命名空间
  

  state,
  actions,
  mutations
}